class code3 {
    public int rob(int[] nums) {
        int a = 0;
        int b = 0;

        for(int x:nums) {
            int c = Math.max(b,a+x);
            a = b;
            b = c;
        }
        return b;
    }
}